from zope.interface import Interface
from zope import schema

from meercat.interfaces import IOrderedRegistry
from meercat.harvester.base.interfaces import IFileHarvester



class ISFXField(Interface):
    def __call__(self, value):
        """ Return an xml.etree.Element, iterable container of Elements or None 
        based on the input value """

class ISFXFilter(Interface):
    def __call__(self, value):
        pass

class ISFXTokenizer(Interface):
    def __call__(self, value):
        pass
    

class ISFXTagField(ISFXField):
    tag = schema.TextLine()
    attributes = schema.Dict(value_type=schema.TextLine())
    filter = schema.Object(schema=ISFXFilter)

class ISFXTokenizedTagField(ISFXTagField):
    tokenizer = schema.Object(schema=ISFXTokenizer)

class ISFXFieldSet(Interface):
    fields = schema.Object(schema=IOrderedRegistry)
    format = schema.TextLine()
    tag = schema.TextLine()
    
    def render(self, source, values):
        """ Render a Metadata object for the input values """

class ISFXDefaultFieldSets(IOrderedRegistry):
    pass
    
class ISFXHarvester(IFileHarvester):
    source = schema.TextLine()
    fieldsets = schema.Object(schema=IOrderedRegistry)
    dialect = schema.TextLine()
    identifier = schema.Int()

